﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dne.GridExt.Models
{
    public class DneGrid
    {
        public string Url { get; set; }

        public string Id { get; private set; }

        public Columns Columns { get; private set; }

        public DneGrid(string id)
        {
            Id = id;

            Columns = new Columns();
        }


    }

    public class Columns : IColumns, IEnumerable<IColumn>
    {
        private IList<IColumn> _columnsCollection = new List<IColumn>();

        public IColumns Add(IColumn column)
        {
            _columnsCollection.Add(column);
            return this;
        }

        public IEnumerator<IColumn> GetEnumerator()
        {
            return _columnsCollection.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public IColumn this[int i]
        {
            get { return _columnsCollection[i]; }
        }
    }

    public interface IColumn
    {
        string Name { get; }
        string Index { get; }
    }

    public class Column : IColumn
    {
        private readonly string _index;
        private readonly string _name;

        public Column(string index, string name)
        {
            _index = index;
            _name = name;
        }

        public string Name
        {
            get { return _name; }
        }

        public string Index
        {
            get { return _index; }
        }
    }

    public interface IColumns
    {
        IColumns Add(IColumn column);
    }
}
